package com.dc.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;

import javax.persistence.*;
import java.util.Date;

/**
 *  船体割旧 单船工序
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "t_workflow_ship_old")
public class WorkflowShipOldEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "submit_time")
    @JsonFormat(pattern = "yyyy-MM-dd")
    // 生成
    private Date submitTime = new Date();        // 填写日期

    @Transient
    private Long shipRepairId;      // 维修记录 外键id

    @Transient
    private String shipName;        // 船体名称

    @Transient
    private String reporter;        // 填报人

    @Column(name = "room", length = 50)     // 车间
    private String room;

    ////////////////////////////////////////////
    @Column(name = "type", length = 20)
    private String type;            // 类型 外板/筋板

    @Column(name = "thickness")
    private Double thickness;	    // 厚(mm)

    @Column(name = "width")
    private Double width;           // 宽(mm)

    @Column(name = "num")
    private Double num;             // 数量

    @Column(name = "length")
    private Double length;          // 长(mm)

    @Transient
    private Double totalLength;     // 切割总长(mm)  	length

    @Transient
    private Double gasByUnit;       // 单位耗天然气量标定值

    @Transient
    private Double gas;             // 天然气	totalLength * gasByUnit

    @Transient
    private Double o2ByUnit;        // 单位耗氧气量标定值

    @Transient
    private Double o2;              // 氧气量	totalLength * o2ByUnit

    @Column(name = "create_time")
    @CreationTimestamp
    private Date createTime;

    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ship_repair_id", columnDefinition = "bigint unsigned NOT NULL")
    private ShipRepairEntity shipRepairEntity;
}
